@extends('layouts._app')
@section('content')
    <body>
    <div class="wrap-container">
        @include('layouts._flash')
        <div id="LAY-popup-user-add" class="layui-layer-content">
            <div class="layui-form" lay-filter="layuiadmin-form-label" style="padding: 20px 30px 0 0;">
                {!! Form::open(['route' =>[ 'blog.link.update',$link->id],'class'=>'layui-form','method'=>'put']) !!}
                <div class="layui-form-item">
                    {!! Form::label('','* 名称：',['class'=>'layui-form-label','style'=>'color:red']) !!}
                    <div class="layui-input-block">
                        {!! Form::text('name',"{$link->name}",['required','lay-verify'=>'required','class'=>'layui-input','placeholder'=>'请输入名称']) !!}
                    </div>
                </div>
                <div class="layui-form-item">
                    {!! Form::label('','地址：',['class'=>'layui-form-label']) !!}
                    <div class="layui-input-block">
                        {!! Form::text('url',"{$link->url}",['class'=>'layui-input','placeholder'=>'请输入地址']) !!}
                    </div>
                </div>
                <div class="layui-form-item">
                    {!! Form::label('','图标：',['class'=>'layui-form-label']) !!}
                    <div class="layui-input-block">
                        <img title="友情链接图标" alt="友情链接图标" id="img_show"
                             style="@if(!$link->file) display: none;@endif margin:0 20px 0 0;width: 60px;height: 60px;border-radius: 50%;"
                             src="@if($link->file) {{$link->file->url}} @else {{asset('static/admin/icon/35508.png')}} @endif">
                        <button style="@if(!$link->file) display:none; @endif float: right;" type="button"
                                class="layui-btn layui-btn-small layui-btn-danger delBtn">
                            <i class="layui-icon">&#xe640;</i>
                        </button>
                        <div class="layui-box layui-upload-button">
                            {!! Form::file('',['id'=>'file0','onchange'=>'previewImages(this,0)']) !!}
                            <span class="layui-upload-icon"><i class="layui-icon"></i>上传图片</span>
                        </div>
                    </div>
                    {!! Form::hidden('pic',"{$link->pic}",['id'=>'pic']) !!}
                </div>
                <br>
                <div class="layui-form-item">
                    {!! Form::label('','是否显示：',['class'=>'layui-form-label']) !!}
                    <div class="layui-input-block">
                        <input type="radio" name="is_show" value="1" title="是" {{$link->is_show == 1?'checked':''}}>
                        <input type="radio" name="is_show" value="2" title="否" {{$link->is_show != 1?'checked':''}}>
                    </div>

                </div>
                <div class="layui-form-item">
                    {!! Form::label('','简介：',['class'=>'layui-form-label']) !!}
                    <div class="layui-input-block">
                        {!! Form::textarea('content',"{$link->content}",['class'=>'layui-textarea','placeholder'=>'请输入简介']) !!}
                    </div>
                </div>

            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    {!! Form::submit('确认',['class'=>'layui-btn','lay-filter'=>'formDemo','lay-submit']) !!}
                </div>
            </div>
            {!! Form::close() !!}
        </div>
    </div>
    <script src="{{asset('static/admin/layui/layui.js')}}" type="text/javascript" charset="utf-8"></script>
    <script src="{{asset('js/jquery.min.js')}}" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="{{asset('js/upload.js')}}"></script>
    <script>
        //Demo
        layui.use(['form', 'jquery'], function () {
            var form = layui.form();
            $ = layui.jquery;
            form.render();
            $('.delBtn').click(function () {
                $(this).attr('style', 'display:none');
                $("#pic").val('');
                var img = $("#img_show");
                img.attr('src', '{{asset('static/admin/icon/35508.png')}}');
                img.attr('style', 'display:none');
            })
        })
    </script>
    </body>
@endsection
